<template>
  <div class="app">
    <el-alert v-show="showNotice"
      title="添加管理员成功"
      type="success"
      show-icon style="margin-bottom:20px;">
    </el-alert>
    <el-form ref="form" :model="info" label-width="120px">
      <el-form-item label="用户名">
        <el-input v-model="info.username"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input type="password" v-model="info.password"></el-input>
      </el-form-item>
      <el-form-item label="真实姓名">
        <el-input v-model="info.name"></el-input>
      </el-form-item>
      <el-form-item label="头像地址">
        <el-input v-model="info.avatar"></el-input>
      </el-form-item>
      <el-form-item label="用户类型">
        <el-select v-model="info.role">
          <el-option label="普通管理员" value="1">普通管理员</el-option>
          <el-option label="超级管理员" value="99">超级管理员</el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button size="small" type="primary" v-on:click="submitHandler">添加管理员</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import { add } from '@/api/admin'
export default {
  name: 'AdminAdder',
  data: function() {
    // 属性
    return {
      showNotice: false,
      info: {
        username: "",
        password: "",
        name: "",
        avatar: "",
        role: "1"
      }
    }
  },
  methods: {
    submitHandler() {
      add(this.info).then(response => {
        this.$message.success('添加管理员成功')
      })
    }
  }
}
</script>

